local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_REGEN_DISABLED")

local incombat = false
local delta_min = 1 / 20
local collectgarbage = collectgarbage

frame:SetScript("OnUpdate", function (self, elapsed)
	if not incombat and elapsed < delta_min then
		collectgarbage("step")
	end
end)
frame:SetScript("OnEvent", function (_, event)
	incombat = (event == "PLAYER_REGEN_DISABLED")
end)
frame:Show()
